home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1992 June: ROMin Holiday / ADC Developer CD (1992-06) (''ROMin Holiday'')_iso / Developer Connection - 06-1992.iso / Development Platforms / Apple II / Apple II Sample Code / MPW IIGS SC / SC.021.Dynamo / app.builder / dispatch.a < prev    next >
Encoding:
Text File  |  1990-06-24  |  4.8 KB  |  253 lines  |  [TEXT/MPS ]

  1. ****************************************************************
  2. *                            *
  3. * buildapp.system hub.                    *
  4. *                            *
  5. * Apple II 8-bit application builder and launcher.        *
  6. * Copyright (C) 1990 Apple Computer.            *
  7. * Version 3.1                        *
  8. *                            *
  9. * Written by Eric Soldan, Apple II DTS            *
  10. *                                                              *
  11. * Developer Technical Support Apple II Sample Code             *
  12. *                                                              *
  13. ****************************************************************
  14.  
  15.         case    on
  16.         longi    off
  17.         longa    off
  18.         machine    m6502
  19.  
  20. * asmiigs dispatch.a -o :o:dispatch.obj
  21. * linkiigs -x :o:dispatch.obj -o :o:dispatch.lnk
  22. * makebiniigs :o:dispatch.lnk -o :o:dispatch.bin -org $2000
  23. * duplicateiigs -y -mac :o:dispatch.bin :
  24.  
  25. *** (mode bit assignments) **
  26.  
  27. * bit 0 = 0:  User wants ROM active
  28. * bit 0 = 1:  User wants a language card active
  29.  
  30. * bit 1 = 0:  Primary zero-page and language card (if bit 0 says language card)
  31. * bit 1 = 1:  Auxiliary zero-page and language card (if bit 0 says language card)
  32.  
  33. * bit 2 = 0:  Primary $D000 bank of language card (if bit 0 says language card)
  34. * bit 2 = 1:  Auxiliary $D000 bank of language card (if bit 0 says language card)
  35.  
  36. * bit 3 = 0:  Primary 48k
  37. * bit 3 = 1:  Auxiliary 48k
  38.  
  39. * bit 4 = 0:  Initialize aux stack pointer (stored at $101) to $FF
  40. * bit 4 = 1:  Leave aux stack pointer alone (already set up).
  41.  
  42. * bit 7 = 0:  Mode byte is for a segment.
  43. * bit 7 = 1:  Mode byte is for launching.
  44.  
  45. *****************************
  46.  
  47. mode        equ    $62
  48. dest        equ    $63        ;& $64
  49. len        equ    $65        ;& $66
  50. ptr        equ    $9D        ;& $9E
  51. objlen        equ    $9F        ;& $A0
  52.  
  53. off        equ    0
  54. on        equ    1
  55.  
  56. store80        equ    $C000        ;sta
  57. ramrd        equ    $C002        ;sta
  58. ramrdsw        equ    $C013        ;hi=1, aux48
  59. ramwrt        equ    $C004        ;sta
  60. ramwrtsw        equ    $C014        ;hi=1, aux48
  61. altzp        equ    $C008        ;sta
  62. rdaltzp        equ    $C016
  63. pri        equ    $C054        ;page1
  64. aux        equ    $C055        ;page2
  65.  
  66.  
  67. * second read from switch does writing.
  68. rdlans        equ    $C080        ;read lan-card, sec-$d0 bank,
  69. *                    ;write rom (lan-card protect)
  70. wrlans        equ    $C081        ;write lan-card, sec-$D0
  71. *                    ;bank, read rom.
  72. romsel        equ    $C082        ;read/write rom.
  73. rdwrlans        equ    $C083        ;read/write lan-card,
  74. *                    ;sec-$D0 bank.
  75. * $C084-$C087 duplicates of above.
  76. rdlanp        equ    rdlans+8        ;pri-$D0 bank.
  77. wrlanp        equ    wrlans+8        ;pri-$D0 bank.
  78. rdwrlanp        equ    rdwrlans+8    ;pri-$D0 bank.
  79.  
  80.  
  81. *************************
  82.  
  83. start        PROC
  84.  
  85.         jmp    start0
  86.         dc.b    $EE,$EE
  87.         dc.b    65
  88.         dc.b    13,'BUILDAPP.TEXT'
  89.         ds.b    65-14
  90.  
  91.         dc.w    end
  92.  
  93. start0        lda    end        ;First mode byte.
  94.         and    #16
  95.         bne    @a
  96.  
  97.         php            ;Disable interrupts.
  98.         sei
  99.  
  100.         sta    altzp+on        ;Initialize aux stack pointer.
  101.         ldx    #$FF
  102.         stx    $101
  103.         tsx            ;Store current stack pointer.
  104.         inx            ;Adjust for php.
  105.         stx    $100
  106.         sta    altzp+off    ;Back to primary ram.
  107.  
  108.         plp            ;Restore interrupt status.
  109.  
  110. @a        clc
  111.         jsr    selectzp
  112.  
  113.         bit    wrlans
  114.         bit    wrlans        ;Read rom/write ram.
  115.         sta    ramrd+off
  116.         sta    ramwrt+off
  117.         lda    #end
  118.         sta    ptr
  119.         lda    #>end
  120.         sta    ptr+1
  121.  
  122. movefile        ldy    #4
  123. @m        lda    (ptr),y
  124.         sta    |mode,y
  125.         dey
  126.         bpl    @m
  127.  
  128.         jsr    selbank
  129.         lda    mode
  130.         bpl    mfile
  131.         jmp    (dest)        ;Start it.
  132.  
  133. mfile        equ    *
  134.         lda    ptr
  135.         clc
  136.         adc    #5
  137.         sta    ptr
  138.         bcc    @a
  139.         inc    ptr+1
  140.  
  141. @a        ldy    #0
  142.         ldx    len        ;So dec test works.
  143.         inx
  144. @b        dex
  145.         bne    @c
  146.         dec    len+1
  147.         bmi    @d
  148. @c        lda    (ptr),y
  149.         sta    (dest),y
  150.         iny
  151.         bne    @b
  152.         inc    ptr+1
  153.         inc    dest+1
  154.         bne    @b
  155. @d        tya
  156.         clc
  157.         adc    ptr
  158.         sta    ptr
  159.         bcc    movefile
  160.         inc    ptr+1
  161.         bcs    movefile        ;Always.
  162.  
  163. *************************
  164.  
  165. selbank        lda    mode
  166.         and    #8
  167.         beq    @a
  168.         sta    $C005        ;Write aux48.
  169. @a        bit    romsel
  170.         lda    mode
  171.         lsr    a
  172.         bcc    @b        ;User wants rom selected.
  173.         lsr    a
  174.         jsr    selectzp        ;Select which 0page.
  175.         bit    rdwrlans        ;Read/write lan, sec $D0.
  176.         bit    rdwrlans
  177.         lda    mode
  178.         and    #4
  179.         beq    @b
  180.         bit    rdwrlanp        ;Read/write lan, pri $D0
  181.         bit    rdwrlanp
  182. @b        rts
  183.  
  184. *************************
  185.  
  186. selectzp        ror    a        ;cclear=pri / cset=alt
  187.         eor    rdaltzp
  188.         bpl    @rts        ;already have correct 0page.
  189.  
  190.         ldy    #4        ;Save the 0page we need.
  191. @a        lda    mode,y
  192.         sta    @mode,y
  193.         lda    ptr,y
  194.         sta    @ptr,y
  195.         dey
  196.         bpl    @a
  197.  
  198.         pla            ;First, save the return address, since
  199.         sta    @retaddr        ;it will end up on the wrong stack, and
  200.         pla            ;therefore we would not be able to return.
  201.         sta    @retaddr+1
  202.  
  203.         php            ;Switch which stack is being used.
  204.         pla
  205.         sta    @intstat
  206.  
  207.         tsx            ;What is that darned stack pointer anyway?
  208.         asl    rdaltzp        ;Which 0page are we on currently?
  209.  
  210.         sei            ;Now we are getting serious.
  211.         sta    altzp+on
  212.         bcc    @b        ;We were in pri-mem before.
  213.  
  214.         stx    $101        ;Save the current aux stack pointer, since
  215.         ldx    $100        ;we will be changing to pri-mem.  Then
  216.         sta    altzp+off    ;choose primary ram.
  217.         bcs    @c
  218.  
  219. @b        stx    $100
  220.         ldx    $101
  221.  
  222. @c        txs            ;Set the stack pointer
  223.         lda    @intstat
  224.         pha
  225.         plp            ;Now we can lighten up.
  226.  
  227.         lda    @retaddr+1    ;Show the way home.
  228.         pha
  229.         lda    @retaddr
  230.         pha
  231.  
  232.         ldy    #4        ;Save the 0page we need.
  233.         lda    @mode,y
  234.         sta    mode,y
  235.         lda    @ptr,y
  236.         sta    ptr,y
  237.         dey
  238.         bpl    @c
  239.  
  240. @rts        rts
  241.  
  242. @mode        ds.b    5
  243. @ptr        ds.b    5
  244. @retaddr        ds.b    2
  245. @intstat        ds.b    1
  246.  
  247. end        equ    *
  248.  
  249.         endp
  250.  
  251.         END
  252.  
  253.